package Homeworks.HOMEWORK0301;

public class Homework1 {
    public static void main(String[] args) {
        double[] list = {1.9, 2.9, 3.4, 3.5};

        // 打印所有数组元素
        print(list);
        // 计算所有元素的总和
        sum(list);
        // 查找最大
        max(list);
        // 查找最小
        min(list);
    }
    public static void print(double[] array) {
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i] + " ");
        }
    }
    public static void sum(double[] array){
        int sum=0;
        for(int i=0;i<array.length;i++){
            sum+=array[i];
        }
        System.out.println("sum="+sum);
    }
    public static void max(double[] array) {
        double max = array[0];
        for(int i=1;i<array.length;i++){
            if (array[i]>max) max=array[i];
        }
        System.out.println("Max is " + max);
    }
    public static void min(double[] array) {
        double min = array[0];
        for(int i=1;i<array.length;i++){
            if (array[i]<min) min=array[i];
        }
        System.out.println("min is " + min);
    }
}
